import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class Serializadora {
	private ObjectInputStream lectorDeObjetos;
	private ObjectOutputStream escritorDeObjetos;

	public void escribirObjeto(Object objeto) {
		try {
			escritorDeObjetos = new ObjectOutputStream(new FileOutputStream(
					"objeto.dat"));
			escritorDeObjetos.writeObject(objeto);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public Object leerObjeto(String nombreDelArchivo) {
		Object retorno = null;
		
		try {
			lectorDeObjetos = new ObjectInputStream(new FileInputStream(
					nombreDelArchivo));
			retorno = lectorDeObjetos.readObject();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return retorno;
	}
}
